﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Maps.MapControl;
using System.Xml.Serialization;
using MyFloridaHouse.ServiceConn.DistrBldrSvcRef;

namespace MyFloridaHouse.libSvOpenDistricts.Districts
{
    public class DistrictSubShapeMetadata
    {
        [XmlAttribute]
        public string uriString { get; set; }
        public BoundingBoxDTO boundingBox { get; set; }


        public static List<DistrictSubShapeMetadata> GetSubShapeMetadata(bool isContiguous, ObservableCollection<BoundingBoxDTO> districtSubShapeDTOList)
        {
            List<DistrictSubShapeMetadata> subShapeList = new List<DistrictSubShapeMetadata>();
            foreach (var sortedSubShape in districtSubShapeDTOList)
            {
                DistrictSubShapeMetadata newSubShape = DistrictSubShapeMetadata.BuildSubShapeMetadata(sortedSubShape);
                if (isContiguous)
                {
                    //newSubShape.uriString = "Solid";
                    newSubShape.uriString = "Images/IconDistrictSolid.jpg";
                }
                else
                {
                    //newSubShape.uriString = "Straggler";
                    newSubShape.uriString = "Images/IconDistrictStraggler.jpg";
                }

                subShapeList.Add(newSubShape);
            }

            return subShapeList;
        }

        public static List<DistrictSubShapeMetadata> GetSubShapeHoleMetadata(ObservableCollection<BoundingBoxDTO> districtSubShapeDTOList)
        {
            List<DistrictSubShapeMetadata> subShapeHoleList = new List<DistrictSubShapeMetadata>();
            foreach (var sortedSubShape in districtSubShapeDTOList)
            {
                DistrictSubShapeMetadata newSubShape = DistrictSubShapeMetadata.BuildSubShapeMetadata(sortedSubShape);
                subShapeHoleList.Add(newSubShape);
            }

            return subShapeHoleList;
        }

        private static DistrictSubShapeMetadata BuildSubShapeMetadata(BoundingBoxDTO subShape)
        {
            DistrictSubShapeMetadata newSubShape = new DistrictSubShapeMetadata();
            newSubShape.boundingBox = new BoundingBoxDTO();
            newSubShape.boundingBox.northWest = subShape.northWest;
            newSubShape.boundingBox.southEast = subShape.southEast;
            newSubShape.uriString = "";
            return newSubShape;
        }
    }
}
